/**
 * @file remoteTask.h
 * @brief 遥控器控制任务头文件
 * @author TuxMonkey (nqx2004@gmail.com)
 * @version 1.0
 * @date 2024-09-21
 * 
 * @copyright Copyright (c) 2024  DLMU-C.ONE
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version <th>Author  <th>Description
 * <tr><td>2024-09-21 <td>1.0     <td>TuxMonkey     <td>内容
 * </table>
 */

#ifndef ___REMOTETASK_H___
#define ___REMOTETASK_H___

#include "cmsis_os.h"
#include "main.h"

void remoteTask(void const * argument);

#define BUFF_SIZE	25

#define RC_SW_UP      1
#define RC_SW_MID     3
#define RC_SW_DOWN    2

extern uint8_t rx_buff[BUFF_SIZE];

typedef struct
{
    uint16_t online;
    //joystick channel value
    
    struct
    {
        int16_t ch[10];
    } rc;

    struct
    {
        /* STICK VALUE */
        int16_t left_vert;
        int16_t left_hori;
        int16_t right_vert;
        int16_t right_hori;
    } joy;

    struct
    {
        /* VAR VALUE */
        float a;
        float b;
    } var;

    struct
    {
        /* KEY VALUE */
        uint8_t a;
        uint8_t b;
        uint8_t c;
        uint8_t d;
        uint8_t e;
        uint8_t f;
        uint8_t g;
        uint8_t h;
    } key;
     
} remoter_t;

typedef struct
{
    uint8_t sw_a; // SWA
    uint8_t sw_b; // SWB
    uint16_t sw_c; // SWC
    uint8_t sw_d; // SWD
    int16_t ch1; // 通道1 (云台yaw)
    int16_t ch2; // 通道2 (云台pitch)
    int16_t ch3; // 通道3 (前后)
    int16_t ch4; // 通道4 (左右)
    uint8_t sw_a_last;
    uint8_t sw_b_last;
    uint16_t sw_c_last;
    uint8_t sw_d_last;
    uint8_t sw_a_up_to_down_flag;
    uint8_t sw_b_up_to_down_flag;
    uint8_t sw_c_midtoup_flag;
    uint8_t sw_c_uptomid_flag;
    uint8_t sw_c_midtodown_flag;
    uint8_t sw_c_downtomid_flag;
    uint8_t sw_d_up_to_down_flag;
} rc_ctrl_t;


#endif